import Vue from 'vue'
import Veevalidate from 'vee-validate';
import zh_CN from 'vee-validate/dist/locale/zh_CN'
Vue.use(Veevalidate)

// 表单验证
Veevalidate.Validator.localize('zh_CN', {
  messages: {
    ...zh_CN.messages,
    is: (field) => `${field}必须与密码相等`  //修改内置规则的message,让确认密码和密码相同
  },
  attributes: {  /// 给校验的 field 属性名映射中文名称
    phone: '手机号',
    code: '验证码',
    password: '密码',
    pwd2: '确认密码',
    clause: '协议'
  }
})

// 自定义检验规则
Veevalidate.Validator.extend('tongyi', {
  validate: (value) => {
    return value
  },
  getMessage: (field) => field + '必须同意'
})